package service;

import mapper.LoginMessageMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import po.LoginMessage;


@Service(value = "judgeServiceImpl")
public class JudgeServiceImpl implements JudgeService{

    //日志文件类
    private static final Logger logger = LoggerFactory.getLogger(JudgeServiceImpl.class);

    //自动注入数据库接口文件的代理类
    @Autowired
    private LoginMessageMapper loginMessageMapper;


    @Override
    public boolean loginValidation(LoginMessage requestLoginMessage){

        String account = requestLoginMessage.getAccount();
        String password = requestLoginMessage.getPassword();

        logger.debug("account的请求值是：" + account);
        logger.debug("password的请求值是：" + password);
        LoginMessage responseLoginMessage = null;
        try {
            responseLoginMessage = loginMessageMapper.searchAccount(account);
        } catch (Exception e) {
            logger.debug("loginMessage的值是：" + responseLoginMessage + "!!!!");
            e.printStackTrace();
        }

        if (responseLoginMessage == null){
            return false;
        }else {
            if (responseLoginMessage.getPassword().equals(password)){
                return true;
            }else {
                return false;
            }
        }
    }



}
